package com.kexio.sms.entity;

import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.kexio.common.entity.BaseEntity;

/**
 * 短信发送记录
 * 
 * @author Kexio Team
 * @since 1.0.0
 */
@TableName("sms_record")
public class SmsRecord extends BaseEntity {
    
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;
    
    /**
     * 手机号码
     */
    @TableField("phone")
    private String phone;
    
    /**
     * 短信内容
     */
    @TableField("content")
    private String content;
    
    /**
     * 模板ID
     */
    @TableField("template_id")
    private String templateId;
    
    /**
     * 模板参数 (JSON格式)
     */
    @TableField("template_params")
    private String templateParams;
    
    /**
     * 短信类型 (verification, notification, marketing)
     */
    @TableField("sms_type")
    private String smsType;
    
    /**
     * 服务提供商 (aliyun, tencent, huawei)
     */
    @TableField("provider")
    private String provider;
    
    /**
     * 发送状态 (pending, success, failed)
     */
    @TableField("status")
    private String status;
    
    /**
     * 发送时间
     */
    @TableField("send_time")
    private LocalDateTime sendTime;
    
    /**
     * 第三方返回的消息ID
     */
    @TableField("message_id")
    private String messageId;
    
    /**
     * 错误码
     */
    @TableField("error_code")
    private String errorCode;
    
    /**
     * 错误信息
     */
    @TableField("error_message")
    private String errorMessage;
    
    /**
     * 重试次数
     */
    @TableField("retry_count")
    private Integer retryCount;
    
    /**
     * 发送耗时 (毫秒)
     */
    @TableField("duration")
    private Long duration;
    
    /**
     * 业务标识
     */
    @TableField("business_type")
    private String businessType;
    
    /**
     * 业务关键字
     */
    @TableField("business_key")
    private String businessKey;
    
    // Constructors
    public SmsRecord() {}
    
    public SmsRecord(String phone, String content, String smsType, String provider) {
        this.phone = phone;
        this.content = content;
        this.smsType = smsType;
        this.provider = provider;
        this.status = "pending";
        this.sendTime = LocalDateTime.now();
        this.retryCount = 0;
    }
    
    // Getters and Setters
    public String getId() { return id; }
    public void setId(String id) { this.id = id; }
    
    public String getPhone() { return phone; }
    public void setPhone(String phone) { this.phone = phone; }
    
    public String getContent() { return content; }
    public void setContent(String content) { this.content = content; }
    
    public String getTemplateId() { return templateId; }
    public void setTemplateId(String templateId) { this.templateId = templateId; }
    
    public String getTemplateParams() { return templateParams; }
    public void setTemplateParams(String templateParams) { this.templateParams = templateParams; }
    
    public String getSmsType() { return smsType; }
    public void setSmsType(String smsType) { this.smsType = smsType; }
    
    public String getProvider() { return provider; }
    public void setProvider(String provider) { this.provider = provider; }
    
    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }
    
    public LocalDateTime getSendTime() { return sendTime; }
    public void setSendTime(LocalDateTime sendTime) { this.sendTime = sendTime; }
    
    public String getMessageId() { return messageId; }
    public void setMessageId(String messageId) { this.messageId = messageId; }
    
    public String getErrorCode() { return errorCode; }
    public void setErrorCode(String errorCode) { this.errorCode = errorCode; }
    
    public String getErrorMessage() { return errorMessage; }
    public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
    
    public Integer getRetryCount() { return retryCount; }
    public void setRetryCount(Integer retryCount) { this.retryCount = retryCount; }
    
    public Long getDuration() { return duration; }
    public void setDuration(Long duration) { this.duration = duration; }
    
    public String getBusinessType() { return businessType; }
    public void setBusinessType(String businessType) { this.businessType = businessType; }
    
    public String getBusinessKey() { return businessKey; }
    public void setBusinessKey(String businessKey) { this.businessKey = businessKey; }
}
